

<?php
    if (!isset($_GET['preview'])):

        $price_for_no_days = calculateDays($_GET['check_in'], $_GET['check_out'], TRUE);

        $night_s = $price_for_no_days > 1 ? lang('res.nights') : lang('res.night');

    endif;

    $cnt = count($results);
    for ($i = 0; $i < $cnt; $i++):

        if (!isset($_GET['preview'])) {

            $build_G = $_GET;
            if ($build_G['dest_hot'] == "")
                $build_G['dest_hot'] = -1;

            unset($build_G['lang']);

            $build_GET = http_build_query($build_G);
        }else {
            $build_GET = '&preview=1';
        }

        $obj_name = URLify::filter($results[$i]->object_name);
        $href = lang_url('accommodation/' . $obj_name . '-' . $results[$i]->object_ID . '?' . $build_GET . '&room_id=' . $results[$i]->rooms[0]->room_ID);
        $thumbnail = HOST_URL_HOTELS . $results[$i]->photo_path . '/thumb_207x136/' . $results[$i]->photo_name;
        ?>
        <li class="js_item" id="box-<?= $results[$i]->object_ID ?>" style="display: none" data-id='<?= $results[$i]->object_ID ?>'>

            <div class="box clearfix gradient5">

                <div class="white_line"></div>

                <div class="rating">

                    <? if (isset($results[$i]->object_number_of_stars) && $results[$i]->object_number_of_stars != ""): ?>
                    <span class="hotel-star-small star_<?= $results[$i]->object_number_of_stars ?> pull-left">&nbsp;</span>
                    <? endif; ?>
                </div>

                <div class="result-price"><div class="from"><?= lang('from'); ?></div><?= !isset($_GET['preview']) ? $results[$i]->rooms[0]->selling_price : $results[$i]->lowest_price; ?> <?= lang(currency_sign()); ?> </div>

                <div class="controls">
                    <a href="#myCarousel<?= $i ?>" data-slide="prev" class="prev pull-left carousel-control left">&nbsp;</a>
                    <a href="#myCarousel<?= $i ?>" data-slide="next" class="next pull-right carousel-control right">&nbsp;</a>
                </div>

                <? if (isset($results[$i]->object_recommended) && $results[$i]->object_recommended == '1'): ?>
                <div class="recomended"></div>
                <? endif; ?>

                <? if (!isset($_GET['preview'])): ?>
                <div class="show_how_meny_nights"><?= lang('res.price_for'); ?> <?= $price_for_no_days ?> <?= $night_s ?></div>
                <? endif; ?>

                <div id="myCarousel<?= $i ?>" class="carousel slide" data-interval="false">

                    <!-- Carousel items -->
                    <div class="carousel-inner">
                        <?php
                        $z = TRUE;
                        foreach ($results[$i]->photos as $photo):

                            $thumbnail = HOST_URL_HOTELS . $photo->path . '/thumb_182x123/' . $photo->photo_name;
                            ?>    
                            <div class="item <? if ($z) echo 'active'; ?>">
                                <a href="<?= $href ?>">
                                    <!--<img src="<? // $thumbnail          ?>">-->
                                </a>
                            </div>

                            <?php
                            $z = FALSE;
                        endforeach;
                        ?>
                    </div>

                </div>


                <div class="details">
                    <h2><a href="<?= $href ?>"><?= $results[$i]->object_name ?></a></h2>

                    <div class="destination">

                        <? if (isset($results[$i]->object_x_coordinate) && $results[$i]->object_x_coordinate != "" && isset($results[$i]->object_y_coordinate) && $results[$i]->object_y_coordinate != ""): ?>

                        <a href='javascript:' class="show_map" data-id="<?= $results[$i]->object_ID ?>"><img src="<?= base_url() ?>assets/img/showonmap_<?= $this->lang->mci_current() ?>.png" alt="" title="<?= lang('map.show_on_map'); ?>"></a>

                        <? endif; ?>

                        <p class="ellipsis dest_beside_showmap"><?= $results[$i]->destination_name ?></p>
                        <p class="ellipsis"><?= lang('montenegro') ?></p>
                    </div>    

                    <p class="small-desc">
                        <?
                        $string = strip_tags($results[$i]->object_info);
                        echo substr($string, 0, 90) . '...';
                        ?>
                    </p>
                </div>

            </div>

            <div class="table-holder">
                <table class="table table-condensed table-hover rooms">
                    <tbody>
                        <tr>
                            <th><?= lang('res.accommodation'); ?></th>
                            <th><?= lang('res.service'); ?></th>
                            <th><?= lang('res.total_price'); ?></th>
                            <th><?= lang('res.booking'); ?></th>
                        </tr>
                        <?php
                        $k = 0;
                        $none = "style='display:none'";

                        foreach ($results[$i]->rooms as $room):
                            $href_room = lang_url('accommodation/' . $obj_name . '-' . $results[$i]->object_ID . '?' . $build_GET . '&room_id=' . $room->room_ID);
                            $person_s = $room->room_max_person > 1 ? lang('res.persons') : lang('res.person');

                            if ($this->lang->mci_current() == 'me'):

                                if ($room->room_max_person == 1)
                                    $person_s = lang('res.person');
                                else if ($room->room_max_person >= 2 && $room->room_max_person <= 4)
                                    $person_s = lang('res.persone');
                                else
                                    $person_s = lang('res.persons');

                            endif;

                            $k++;
                            ?>
                            <tr <?= $k > 3 ? $none : '' ?>>
                                <td>
                                    <a href="<?= $href_room ?>">
                                        <div class="maxps ps_<?= $room->room_max_person ?>" title="<?= lang('form.for'); ?> <?= $room->room_max_person ?> <?= $person_s ?>"></div>
                                        <?= lang('room.' . underscore($room->room_type_name)); ?> <span class="gray"><?= $room->room_description ?></span>

                                    </a>
                                </td>
                                <td class="gray"><?= $room->service_name ?></td>
                                <td class="price"><? if (!isset($_GET['preview'])) echo $room->total . ' '. lang(currency_sign()); ?> </td>

                                <?
                                switch ($room->room_selling_type_ID) {
                                case 1:
                                ?>
                                <td class="request">
                                    <!--<a href="<?= $href_room ?>"></a>-->
                                    <a class="" href="<?= $href_room ?>"><?= lang('res.send_request'); ?></a>
                                </td>
                                <?
                                break;

                                case 2:
                                ?><td class="realtime">
                                    <a class="" href="<?= $href_room ?>"><?= lang('res.book_now'); ?></a>

                                </td><?
                                break;
                                };
                                ?>


                            </tr>
                        <?php endforeach; ?>




                    </tbody>
                </table>

                <?php if ($k > 3): ?>
                    <div class="list_more">
                        <a href="javascript:" class="show_more more" data-id="more" data-elem=".rooms" data-find="tr">+ <?= lang('more_rooms') ?> (<?= $k - 3 ?>)</a>
                        <a href="javascript:" class="show_more less" data-id="less" data-elem=".rooms" data-find="tr" <?= $none ?>>- <?= lang('hide_rooms') ?> </a>
                    </div>

                <?php endif; ?>

            </div>

        </li>

    <?php endfor; ?>